<?php
require_once $_SERVER['DOCUMENT_ROOT'].'/../common.php';

if ($_POST)
{
	$file = array_shift($_FILES);
	print_r($file);
}

page::printTop();
?>

<div id="file-uploader">       
    <noscript>          
        <p>Please enable JavaScript to use file uploader.</p>
        <!-- or put a simple form for upload here -->
    </noscript>         
</div>

<div id="file-list"></div>

<script>
$(function(){
	var uploader = new qq.FileUploader({
	        elementTemplate: '<img src=# height=300 />',        
        
		element:$('#file-uploader')[0],
		//action: '/server/port/upload/',
		action: 'upload.php',
		params: {},
		allowedExtensions: ['jpg', 'jpeg', 'png', 'gif', 'bmp'],        
		debug: false,
		onSubmit: function(id, fileName){},
		onProgress: function(id, fileName, loaded, total){},
		onComplete: function(id, fileName, responseJSON){
			//alert(responseJSON.upname);
			//var item = qq.toElement(this.elementTemplate);                
/*			var fileElement = this._find(item, 'file');        
			qq.setText(fileElement, this._formatFileName(fileName));
			this._find(item, 'size').style.display = 'none';*/
			
			$('#file-list').append("<img height=200 src='"+responseJSON.upname+"' />");
		},
		onCancel: function(id, fileName){},
		messages: {
		},
		showMessage: function(message){ alert(message); }
	});
});
</script>

<?php
page::printTail();
